﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StockholmsStad.Runtime.Serialization.DataContract;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace StockholmsStad.Windows.UI.Modules.Maintenance.Models
{
    public class InformationTextPresentationModel : INotifyPropertyChanged
    {
        public InformationTextPresentationModel()
        {

        }

        public string HeaderInfo
        {
            get { return HeaderNames.InformationTexts; }
        }

        private List<ValueIdPair> textTypes;
        public List<ValueIdPair> TextTypes
        {
            get { return textTypes; }
            set { textTypes = value; }
        }

        private ObservableCollection<InformationText> texts;
        public ObservableCollection<InformationText> Texts
        {
            get { return texts; }
            set
            {
                    texts = value;
                    NotifyPropertyChanged("Texts");

                    //if (texts.Count > 0)
                    //    SelectedInformationText = texts[0];
            }
        }

        private InformationText selectedInformationText;
        public InformationText SelectedInformationText
        {
            get 
            {
                return selectedInformationText; 
            }
            set 
            { 
                selectedInformationText = value;
                if(PropertyChanged != null)
                    NotifyPropertyChanged("SelectedInformationText");
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            if(PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion

        public void AddText(InformationText item)
        {
            texts.Add(item);
            //NotifyPropertyChanged("Texts");       
        }

        public void DeleteText(InformationText item)
        {
            texts.Remove(item);
            //NotifyPropertyChanged("Texts");
        }
    }
}
